package com.tony.rpc.client;

import com.tony.rpc.center.CenterService;
import com.tony.rpc.center.Server;
import com.tony.rpc.service.HelloService;
import com.tony.rpc.service.HelloServiceImpl;

import java.io.IOException;
import java.net.InetSocketAddress;

public class ClientTest {
    public static void main(String[] args) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Server serviceServer = new CenterService(8888);
                    serviceServer.register(HelloService.class, HelloServiceImpl.class);
                    serviceServer.start();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }).start();

        HelloService service = RpcClient.getRemoteProxyObj(HelloService.class,new InetSocketAddress("localhost",8888));
        System.out.println(service.sayHi("tony" ));
    }
}
